<?php 
require_once('autoloader.php');
include("dailypenfunctions.php"); 
include("rss.php"); 
include("twitter.php"); 

// GLOBAL VARS
$version = "1.0.0.10001";
$GLOBALS['errors'] = "";
$now = new DateTime();
$now->setTimezone(new DateTimeZone('America/Montreal'));
$formatted = $now->format('Y-m-d')."T".$now->format('H:i:s').".000Z";
$headlines = array(
	"http://rss.radio-canada.ca/fils/regions/quebec.xml",
	"http://rss.radio-canada.ca/fils/regions/estduquebec.xml",
	"http://rss.radio-canada.ca/fils/nouvelles/international.xml",
	"http://www.cyberpresse.ca/rss/225.xml",
	"http://www.cyberpresse.ca/rss/501.xml");
	
echo "<html>\r\n";
echo "<head>\r\n";
echo "<title>The Daily Pen, ".$now->format('F j')."</title>\r\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html\" charset=\"UTF-8\" />\r\n";
echo "<meta property=\"og:title\" content=\"The Daily Pen\" />\r\n";
echo "<meta property=\"og:type\" content=\"article\" />\r\n";
echo "<meta property=\"og:url\" content=\"http://www.touzel.com/daily.php\" />\r\n";
echo "<meta HTTP-EQUIV=\"CACHE-CONTROL\" content=\"NO-CACHE\" />\r\n";
echo "<meta HTTP-EQUIV=\"PRAGMA\" content=\"NO-CACHE\" />\r\n";
echo "<meta HTTP-EQUIV=\"Expires\" content=\"-1\" />\r\n";
echo "<meta HTTP-EQUIV=\"cache-control\" content=\"max-age=0\" />\r\n";
echo "<meta property=\"og:image\" content=\"http://www.touzel.com/logo2.png\" />\r\n";
echo "<meta property=\"author\" content=\"Christian Touzel\">\r\n";
echo "<meta property=\"version\" content=\"".$version."\">\r\n";
echo "<meta property=\"article:published_time\" content=\"".$formatted."\" />\r\n";
echo "<meta property=\"article:modified_time\" content=\"".$formatted."\" />\r\n";
echo "</head>\r\n";
echo "<body>\r\n";
echo "<article>\r\n";
echo "<h1>The Daily Pen, ".$now->format('F j')."</h1>\r\n";
echo "<section>\r\n";
echo GetRandomQuote();
echo GetWeather(true);
echo GetWeather(false);
echo "<h3>DERNIERE HEURE</h3>".GetHeadlinesFromRSS($headlines, 8, 0);
echo "<h3>BASEBALL</h3>".GetHeadlinesFromRSS("http://mlb.mlb.com/partnerxml/gen/news/rss/mlb.xml", 8, 0);
	
// GOOGLE CALENDAR
// ???

// TODOIST
//echo GetTodoistTasks();

// TWITTER
echo "<h3>TWITTER</h3>".GetTwitterTimeline();

// MLB NEWS
echo ReadFromRSS("http://mlb.mlb.com/partnerxml/gen/news/rss/mlb.xml", "MLB NEWS", 7, false, 0);

// MLB SCORES
echo "<h3>MLB SCORES</h3>\r\n";
GetMLBScoresTables();

// MLB STANDINGS
echo "<h3>MLB STANDINGS</h3>\r\n";
GetMLBStandings2()."\r\n\r\n";

// MLB STATS
echo "<h3>MLB STATS</h3>\r\n";
GetMLBStats()."\r\n\r\n";

echo ReadFromRSS(array('http://joeposnanski.com/joeblogs/feed/','http://www.nbcsports.com/rss/author/joe-posnanski/feed/'), "JOE POSNANSKI", 1, true, 0);
echo ReadFromRSS("http://sports.yahoo.com/mlb/blog/big_league_stew/rss.xml", "KEVIN KADUK", 1, true, 0);

// LOG REPORTS
echo "<h3>ERRORS REPORT</h3>";
echo $GLOBALS['errors'];
echo "<p style='font-size: 80%;'>The Daily Pen ".$version." is a creation of Christian Touzel. ";
echo "Page generated on ".$now->format('F j, Y H:i:s').". PHP version is ".phpversion()."</p>";

?>
</section>
</article>
</body>
</html>